package com.itheima.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class AOPAdvice {

    @Pointcut("execution(* *..*(..))")
    public void pt(){
    }

//    @Before("pt()")
    public void before() {
        System.out.println("前置。。。。。");
    }

//    @After("pt()")
    public void after() {
        System.out.println("后置。。。。。");

    }

//    @AfterThrowing("pt()")
    public void afterThrowing() {

        System.out.println("异常通知");
    }

    @Around("pt()")
    public Object around(ProceedingJoinPoint pp) throws Throwable {
        System.out.println("环绕通知前");
        Object p = pp.proceed();
        System.out.println("环绕通知后");
        return p;
    }

}
